/**
 * @author LKQ
 * @date 2022/2/14 21:03
 * @description 计数
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println( solution.minOperations("0100"));
    }
    public int minOperations(String s) {
        // cnt1记录把字符串变成偶数为0，奇数位为1的修改次数， cnt2 记录把字符串变成偶数
        // 为1, 奇数位为1的修改次数，取最少次
        int cnt1 = 0, cnt2 = 0;
        for (int i = 0; i < s.length(); i++) {
            if ( s.charAt(i) -'0' != i % 2) {
                cnt1++;
            }else {
                cnt2++;
            }
        }
        return Math.min(cnt1, cnt2);
    }
}
